/*    */ package com.zimbra.cs.service.admin;
/*    */ 
/*    */ import com.zimbra.common.account.Key.ServerBy;
/*    */ import com.zimbra.common.service.ServiceException;
/*    */ import com.zimbra.common.soap.AdminConstants;
/*    */ import com.zimbra.common.soap.Element;
/*    */ import com.zimbra.cs.account.Provisioning;
/*    */ import com.zimbra.cs.account.Server;
/*    */ import com.zimbra.cs.account.accesscontrol.AdminRight;
/*    */ import com.zimbra.cs.zookeeper.CuratorManager;
/*    */ import com.zimbra.soap.ZimbraSoapContext;
/*    */ import java.util.List;
/*    */ import java.util.Map;
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ public final class SetServerOffline
/*    */   extends AdminDocumentHandler
/*    */ {
/*    */   public Element handle(Element request, Map<String, Object> context)
/*    */     throws ServiceException
/*    */   {
/* 37 */     ZimbraSoapContext zsc = getZimbraSoapContext(context);
/* 38 */     checkRight(zsc, context, null, AdminRight.PR_SYSTEM_ADMIN_ONLY);
/* 39 */     Element response = zsc.createElement(AdminConstants.SET_SERVER_OFFLINE_RESPONSE);
/* 40 */     CuratorManager curator = CuratorManager.getInstance();
/* 41 */     if (curator == null) {
/* 42 */       return response;
/*    */     }
/*    */     
/* 45 */     Element d = request.getElement("server");
/* 46 */     String method = d.getAttribute("by");
/* 47 */     String name = d.getText();
/*    */     
/* 49 */     if ((name == null) || (name.equals(""))) {
/* 50 */       throw ServiceException.INVALID_REQUEST("must specify a value for a server", null);
/*    */     }
/* 52 */     Server server = Provisioning.getInstance().get(Key.ServerBy.fromString(method), name);
/*    */     try {
/* 54 */       curator.unregisterService(server.getId());
/*    */     } catch (Exception e) {
/* 56 */       throw ServiceException.FAILURE("error while unregistering the server", e);
/*    */     }
/* 58 */     return response;
/*    */   }
/*    */   
/*    */   public void docRights(List<AdminRight> relatedRights, List<String> notes)
/*    */   {
/* 63 */     notes.add("Only system admins are allowed.");
/*    */   }
/*    */ }


/* Location:              /home/mint/zimbrastore.jar!/com/zimbra/cs/service/admin/SetServerOffline.class
 * Java compiler version: 7 (51.0)
 * JD-Core Version:       0.7.1
 */